var fs = require('fs');
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
  var data = fs.readFileSync('index.html','utf-8');
  res.send(data);
});
 
io.on('connection', function(socket){
  console.log('a user connected');
  socket.on("disconnect", function() {
    console.log("a user go out");
  });
  socket.on("message", function(obj) {
    io.emit("message", obj);
  });
});
http.listen(3000, function(){
  console.log('listening on *:3000');
});